/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: lengleng (wangiegie@gmail.com)
 */
package com.zy.je.book.module.datasource.controller;

import com.zy.je.book.module.datasource.entity.GenDatasourceConf;
import com.zy.je.book.module.datasource.service.GenDatasourceConfService;
import com.zy.je.common.mybatis.ext.web.BizBaseController;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 数据源管理
 *
 * @author lengleng
 * @date 2019-03-31 16:00:20
 */
@Api(tags = "数据源")
@RestController
@RequiredArgsConstructor
@RequestMapping("/dsconf")
public class GenDsConfController extends BizBaseController<GenDatasourceConf> {

	private final GenDatasourceConfService datasourceConfService;

//	private final Screw screw;
//
//	/**
//	 * 查询数据源对应的文档
//	 * @param dsName 数据源名称
//	 */
//	@SneakyThrows
//	@GetMapping("/doc")
//	public void generatorDoc(String dsName, HttpServletResponse response) {
//		// 设置指定的数据源
//		DynamicRoutingDataSource dynamicRoutingDataSource = SpringContextHolder.getBean(DynamicRoutingDataSource.class);
//		DynamicDataSourceContextHolder.push(dsName);
//		DataSource dataSource = dynamicRoutingDataSource.determineDataSource();
//
//		// 设置指定的目标表
//		ScrewProperties screwProperties = SpringContextHolder.getBean(ScrewProperties.class);
//
//		// 生成
//		byte[] data = screw.documentGeneration(dataSource, screwProperties).toByteArray();
//		response.reset();
//		response.addHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(data.length));
//		response.setContentType(ContentType.OCTET_STREAM.getValue());
//		IoUtil.write(response.getOutputStream(), Boolean.TRUE, data);
//	}

}
